package mammuthus.template.spark_notebook

import mammuthus.master.Master
import mammuthus.template.TemplateProcessor
import mammuthus.protocal.WriteFileTaskResponse
import mammuthus.tool.TemplateTool

/**
 * 6/18/15 WilliamZhu(allwefantasy@gmail.com)
 */
class SparkNotebookProcessor (master: Master) extends TemplateProcessor {
  override def process(fileName: String, targetFilePath: String, params: Map[String, AnyRef]): List[WriteFileTaskResponse] = {
    val appName = params("appName").asInstanceOf[String]
    val app = params.getOrElse("app", appName)
    //val slaves = params.getOrElse("")
    val hadoopName = params.getOrElse("hadoopName","hadoop").asInstanceOf[String]
    val hadoopConfigPath = master.appGetExtra(Map("appName"->hadoopName,"name"->"installPath")).toList(0)("extra")+s"/$hadoopName/etc/hadoop"

    val configStr = s"export HADOOP_CONF_DIR=$hadoopConfigPath "

    master.writeFile("", configStr, targetFilePath, false)

  }
}
